<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
	<HEAD>
		<META CONTENT="text/html; charset=UTF-8" HTTP-EQUIV="Content-Type">
		<TITLE>PI.JS > extend</TITLE>
		<LINK HREF="../../../../../inc/template.css" REL="stylesheet">
		<LINK HREF="../../../../../inc/template.css" REL="stylesheet">
		<SCRIPT SRC="../../../../../source/pi.1.1.1.js" TYPE="text/javascript"></SCRIPT>
		<SCRIPT SRC="../../../../../inc/template.js" TYPE="text/javascript"></SCRIPT>
		<LINK HREF="../../../../../inc/sh/SyntaxHighlighter.css" TYPE="text/css" REL="stylesheet">
		<SCRIPT SRC="../../../../../inc/sh/shCore.js" LANGUAGE="javascript"></SCRIPT>
		<SCRIPT SRC="../../../../../inc/sh/shBrushJScript.js" LANGUAGE="javascript"></SCRIPT>
		<SCRIPT SRC="../../../../../inc/sh/shBrushCss.js" LANGUAGE="javascript"></SCRIPT>
		<SCRIPT SRC="../../../../../inc/sh/shBrushXml.js" LANGUAGE="javascript"></SCRIPT>
		<SCRIPT SRC="../../../../../inc/sh/shBrushPhp.js" LANGUAGE="javascript"></SCRIPT>
		<SCRIPT SRC="../../../../../inc/sh/shBrushPython.js" LANGUAGE="javascript"></SCRIPT>
	</HEAD>
	<BODY>
		<A HREF="/" ID="header" CLASS="Header">
			<EM></EM>
		</A>
		<DIV CLASS="Index">
			<DIV ID="indexContainer" CLASS="ListContainer">
				<A HREF="../../../../../index.html" CLASS="Button "><EM>About Pi</EM></A>
				<A HREF="../../../../../pages/Downloads" CLASS="Button "><EM>Downloads</EM></A>
				<A HREF="../../../../../documentation/index.html" CLASS="Button SelectedButton"><EM>Documentation</EM></A>
				<DIV CLASS="SubNavigation">
					<DIV>
						<H2 CLASS="Title">Essential Documents</H2>
						<UL>
							<LI>
								<A STYLE="" HREF="../../../../../documentation/essential/Getting Started to pi.js/">Getting Started to pi.js</A>
							</LI><LI>
								<A STYLE="" HREF="../../../../../documentation/essential/Object Oriented Programming with pi.js/">Object Oriented Programming with pi.js</A>
							</LI>
						</UL>
					</DIV><DIV>
						<H2 CLASS="Title">Reference</H2>
						<UL>
							<LI>
								<A STYLE="" HREF="../../../../../documentation/env/pi.env/">pi.env</A>
							</LI><LI>
								<A STYLE="" HREF="../../../../../documentation/get/pi.get/">pi.get</A>
							</LI><LI>
								<A STYLE="font-weight:bold" HREF="../../../../../documentation/util/pi.util/">pi.util</A>
								<UL>
									<LI>
										<A HREF="../../../../../documentation/util/pi.util.Array/">pi.util.Array</A>
									</LI><LI>
										<A HREF="../../../../../documentation/util/pi.util.Element/">pi.util.Element</A>
									</LI><LI>
										<A HREF="../../../../../documentation/util/pi.util.Hash/">pi.util.Hash</A>
									</LI><LI>
										<A HREF="../../../../../documentation/util/pi.util.Number/">pi.util.Number</A>
									</LI><LI>
										<A HREF="../../../../../documentation/util/pi.util.String/">pi.util.String</A>
									</LI>
								</UL>
							</LI><LI>
								<A STYLE="" HREF="../../../../../documentation/base/pi.base/">pi.base</A>
							</LI><LI>
								<A STYLE="" HREF="../../../../../documentation/element/pi.element/">pi.element</A>
							</LI><LI>
								<A STYLE="" HREF="../../../../../documentation/xhr/pi.xhr/">pi.xhr</A>
							</LI><LI>
								<SPAN STYLE="font-weight:bold">Native Objects</SPAN>
								<UL>
									<LI>
										<A HREF="../../../../../documentation/Native Objects/Array/">Array</A>
									</LI><LI>
										<A HREF="../../../../../documentation/Native Objects/Function/">Function</A>
									</LI><LI>
										<A HREF="../../../../../documentation/Native Objects/Number/">Number</A>
									</LI><LI>
										<A HREF="../../../../../documentation/Native Objects/String/">String</A>
									</LI>
								</UL>
							</LI><LI>
								<SPAN STYLE="font-weight:bold">Plugins</SPAN>
								<UL>
									<LI>
										<A HREF="../../../../../documentation/plugin/pi.comet/">pi.comet</A>
									</LI><LI>
										<SPAN>pi.cache</SPAN>
									</LI><LI>
										<SPAN>pi.layer</SPAN>
									</LI><LI>
										<A HREF="../../../../../documentation/plugin/pi.storage/">pi.storage</A>
									</LI><LI>
										<SPAN>pi.win</SPAN>
									</LI>
								</UL>
							</LI>
						</UL>
					</DIV>
				</DIV>
				<A HREF="../../../../../pages/Plugins" CLASS="Button "><EM>Plugins</EM></A>
				<A HREF="http://groups.google.com/group/pi-js" CLASS="Button"><EM>Developer Forum</EM></A>
				<A HREF="http://code.google.com/p/pi-js/issues/list" CLASS="Button"><EM>Issues</EM></A>
			</DIV>
		</DIV>
		<!-- <h3 class="ContentNav" id="contentTitle">
			<div>
				<a class="Sel">index.html</a>
			</div>
		</h3>-->
		<DIV ID="documentationContent" CLASS="Content">
			<DIV CLASS="Pad">
				<H1 CLASS="Name"><SPAN>Function.</SPAN>extend</H1>
				<DIV CLASS="ParentLink">&lt; <A HREF="../../">Function</A></DIV>
				<DIV>
				<H2 CLASS="Title">Summary</H2>
				Provides creating javascript classes by using pi.base.With this method you can extend a class with other classes. If not another class will be extended, use the extend method of pi.base.
				</DIV>
				<DIV>
				<H2 CLASS="Title">Syntax</H2>
				<CODE>var <EM>className</EM> = <EM>superClass</EM>.extend({
	"$Init":<EM>Constructor</EM>,
	<EM>property name</EM>:<EM>value</EM>,
	<EM>private member</EM>:<EM>value</EM>
},<EM>boolean skipClonning (optional)</EM>)
</CODE>
				</DIV>
				<DIV CLASS="Text">
					<H2 CLASS="Title">General Usage</H2>
<PRE NAME="code" CLASS="Js">
>>> var myClass = pi.base.extend({
	"$Init":function(_argument){
		this.properties.setProperty(_argument);
	};
	"method":function(){
     	return "Hello World";
 },
	"properties":{ // pi.base clones the hash members automatically
             "_property":0 // private member and getter/setter methods are created automatically.
	}
});
>>> var a = new myClass;
>>> myClass.$Init
function
</PRE>
				</DIV>
				<DIV CLASS="Block">
					<H1>Examples</H1>
					<DIV CLASS="Example">
						<H1>Example #1: Create a class "person" with a class "user" which is extending the class. To test the extended class use trace.</H1>
							<DIV CLASS="View">
								<DIV ID="container"></DIV><SCRIPT SRC="../../examples/extend.js" TYPE="text/javascript"></SCRIPT>
							</DIV>
							<H2>Source files of the above example:</H2>
							<DIV>
								<H3>../../examples/extend.html</H3>
								<PRE NAME="code" CLASS="html">&lt;div id="container">&lt;/div></PRE>
							</DIV><DIV>
								<H3>../../examples/extend.js</H3>
								<PRE NAME="code" CLASS="js">var person = pi.base.extend({
	"$Init":function(_name,_age,_country){
		this.environment.setName(_name).environment.setAge(_age).environment.setCountry(_country);
	},
	"environment":{
		"_name":"", "_age":0, "_country":""
	}
});

var eto = new person("Eto Demerzel","30","Aurora");

var user = person.extend({
	"$Init":function(_email,_password,_name,_age,_country){
		person.$Init.call(this,_name,_age,_country);
		this.environment.setEMail(_email).environment.setPassword(_password);
	},
	"environment":{
		"_eMail":"", "_password":"",
		"_name":"", "_age":0, "_country":""
	}
});

var seldon = new user("hseldon@streeling.edu","dors123raych","Hari Seldon","70","Trantor");

pi.util.Init.push(function(){
	trace(
		pi.get("container"), // asagidaki bilgiler bu element'in icine yazdirilacak.
		"&lt;strong>Person: eto&lt;/strong>",
		"name: "+eto.environment.getName(),
		"age: "+eto.environment.getAge(),
		"country: "+eto.environment.getCountry(),
		"&lt;strong>User: seldon&lt;/strong>",
		"email: "+seldon.environment.getEMail(),
		"password: "+seldon.environment.getPassword(),
		"name: "+seldon.environment.getName(),
		"age: "+seldon.environment.getAge(),
		"country: "+seldon.environment.getCountry()
	);
});</PRE>
							</DIV>
					</DIV>
				</DIV>
				<DIV>
				<H2 CLASS="Title">See Also</H2>
				<UL>
					<LI>
						<A HREF="../../../../../documentation/base/pi.base">pi.base</A>
					</LI><LI>
						<A HREF="../../../../../documentation/essential/Object Oriented Programming with pi.js/">Object Oriented Programming with pi.js</A>
					</LI><LI>
						<A HREF="../../../../../documentation/util/pi.util/Methods/Extend">util.Extend</A>
					</LI>
				</UL>
				</DIV>
			</DIV>
		</DIV>
		<DIV CLASS="Clean"></DIV>
	</BODY> 
</HTML>